"""user_up

Revision ID: f3b62c51d450
Revises: dfdcc49f8374
Create Date: 2024-03-19 09:43:17.287307

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision: str = 'f3b62c51d450'
down_revision: Union[str, None] = 'dfdcc49f8374'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('system_users', sa.Column('user_uuid', sa.VARCHAR(length=32), nullable=True, comment='用户id'))
    op.drop_index('ix_system_users_user_uid', table_name='system_users')
    op.create_index(op.f('ix_system_users_user_uuid'), 'system_users', ['user_uuid'], unique=True)
    op.create_index(op.f('ix_system_users_username'), 'system_users', ['username'], unique=True)
    op.drop_column('system_users', 'user_uid')
    op.drop_column('system_users', 'user_id')
    op.drop_column('system_users', 'register_ip')
    op.drop_column('system_users', 'last_login_ip')
    op.drop_column('system_users', 'weixin_openid')
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('system_users', sa.Column('weixin_openid', mysql.VARCHAR(length=64), nullable=True, comment='微信openId'))
    op.add_column('system_users', sa.Column('last_login_ip', mysql.VARCHAR(length=64), nullable=True, comment='上次登录IP'))
    op.add_column('system_users', sa.Column('register_ip', mysql.VARCHAR(length=64), nullable=True, comment='注册IP'))
    op.add_column('system_users', sa.Column('user_id', mysql.VARCHAR(length=32), nullable=True, comment='用户id'))
    op.add_column('system_users', sa.Column('user_uid', mysql.VARCHAR(length=32), nullable=True, comment='用户id'))
    op.drop_index(op.f('ix_system_users_username'), table_name='system_users')
    op.drop_index(op.f('ix_system_users_user_uuid'), table_name='system_users')
    op.create_index('ix_system_users_user_uid', 'system_users', ['user_uid'], unique=True)
    op.drop_column('system_users', 'user_uuid')
    # ### end Alembic commands ###
